Basic Forms
Calendar - Deletion
- General
- Additional Settings
| Table Name | Form Name | Tab Name | Mode | Enable Table Permissions |
|---|---|---|---|---|
| Calendar (tt_calendar) | Portal - Submission | General | Insert | true |
Custom JavaScript
$(document).ready(function() {
{{ snippets["WrapperAJAX"] }};
try {
if (typeof(Page_Validators) == 'undefined') return;
//* Start Date Validation *//
var startDateValidator = document.createElement('span');
startDateValidator.id = "startDateValidator";
startDateValidator.errormessage = "Start Date must be selected";
startDateValidator.evaluationfunction = function()
{
return (( $("#tt_startdate").val() != ""));
};
Page_Validators.push(startDateValidator);
//* Start Date Validation *//
//* Start Date Validation *//
var endDateValidator = document.createElement('span');
endDateValidator.id = "endDateValidator";
endDateValidator.errormessage = "End Date must be selected";
endDateValidator.evaluationfunction = function()
{
return (( $("#tt_enddate").val() != ""));
};
Page_Validators.push(endDateValidator);
//* Start Date Validation *//
//* Date Range Validation *//
var dateRangeValidator = document.createElement('span');
dateRangeValidator.id = "dateRangeValidator";
dateRangeValidator.errormessage = "End Date cannot be before Start Date ";
dateRangeValidator.evaluationfunction = function()
{
var startDate = new Date($("#tt_startdate").val());
var endDate = new Date($("#tt_enddate").val());
return (( startDate <= endDate ));
};
Page_Validators.push(dateRangeValidator);
}
catch (e)
{
alert("Error during validation:" + e.description);
}
prepareForm();
});
function prepareForm(){
$("#tt_startdate_label").parent().addClass("required");
$("#tt_enddate_label").parent().addClass("required");
$("#InsertButton").parent().closest('#content').append('<button id="SubmissionButton" class="btn btn-primary" onclick="DataProcessing()">Delete</button>');
$("#InsertButton").hide()
}
function DataProcessing(){
var validationResponse = FormValidation();
if(validationResponse){
var start = new Date($("#tt_startdate").val());
var startDate = Date.parse(start).format("yyyy-MM-dd")
var end = new Date($("#tt_enddate").val());
var endDate = Date.parse(end).format("yyyy-MM-dd")
$('#SubmissionButton').text("");
$('#SubmissionButton').append('<span class="fa fa-cog fa-spin" style="display: inline-block !important" aria-hidden="true">');
$('#SubmissionButton').append(" Processing ");
$('#SubmissionButton').prop("disabled",true);
$('.submissionError').remove()
$('#SubmissionButton').parent().append('<span id="deletionLog" style="float:right"><span>')
//Delete Calendar Data
parent.checkValidDeletion(startDate, endDate);
}
}
function FormValidation(){
if(typeof entityFormClientValidate === 'function')
{
if(entityFormClientValidate())
{
if(typeof Page_ClientValidate === 'function')
{
if(Page_ClientValidate(''))
{
return true;
}
}
else
{
return true;
}
}
else
{
return false;
}
}
else
{
if(typeof Page_ClientValidate === 'function')
{
if(Page_ClientValidate(''))
{
return true;
}
}
else
{
return true;
}
}
}
Calendar - Edit
- General
- Additional Settings
- Entity Form Metadata
| Table Name | Form Name | Tab Name | Mode | Resource Source Type | Record ID Parameter Name | Enable Table Permissions |
|---|---|---|---|---|---|---|
| Calendar (tt_calendar) | Portal - Main | General | Edit | Query Sting | id | true |
Actions
Delete
| On Complete | Success message | Button Label | Button Style | Button Placement | Button Alignment |
|---|---|---|---|---|---|
| Refresh | The record has been deleted. | Delete | Button Group | Below Form | Left |
Custom JavaScript
$(document).ready(function() {
try {
if (typeof(Page_Validators) == 'undefined') return;
//* Date Range Validation *//
var dateRangeValidator = document.createElement('span');
dateRangeValidator.id = "dateRangeValidator";
dateRangeValidator.errormessage = "End Date cannot be before Start Date ";
dateRangeValidator.evaluationfunction = function()
{
var startDate = new Date($("#tt_startdate").val());
var endDate = new Date($("#tt_enddate").val());
return (( startDate <= endDate ));
};
Page_Validators.push(dateRangeValidator);
//* Date Range Validation *//
//* Country Validation *//
var countryValidator = document.createElement('span');
countryValidator.id = "countryValidator";
countryValidator.errormessage = "A Country must be selected";
countryValidator.evaluationfunction = function()
{
return (( $("#tt_locationcountry").val() != ""));
};
Page_Validators.push(countryValidator);
//* States Validation *//
//* States Validation *//
var stateValidator = document.createElement('span');
stateValidator.id = "stateValidator";
stateValidator.errormessage = "A State must be selected";
stateValidator.evaluationfunction = function()
{
if ($("#tt_locationcountry_name").val() == "United States of America"){
return (( $("#tt_locationstate").val() != ""))
}
else{
return (( $("#tt_locationstate").val() == ""));
}
};
Page_Validators.push(stateValidator);
//* States Validation *//
//* City Validation *//
var cityValidator = document.createElement('span');
cityValidator.id = "cityValidator";
cityValidator.errormessage = "A City must be selected";
cityValidator.evaluationfunction = function()
{
if ($("#tt_locationstate_name").val() == "New York"){
return (( $("#tt_locationcity").val() != ""))
}
else{
return (( $("#tt_locationcity").val() == ""));
}
};
Page_Validators.push(cityValidator);
//* City Validation *//
//* Day Type Validation *//
var dayTypeValidator = document.createElement('span');
dayTypeValidator.id = "dayTypeValidator";
dayTypeValidator.errormessage = "A Type must be selected";
dayTypeValidator.evaluationfunction = function()
{
return (( $("#tt_daytype option:selected").text() != " "))
};
Page_Validators.push(dayTypeValidator);
//* Day Type Validation *//
//* Working Hours Validation *//
var workingHoursValidator = document.createElement('span');
workingHoursValidator.id = "workingHoursValidator";
workingHoursValidator.errormessage = "Working Hours must be selected";
workingHoursValidator.evaluationfunction = function()
{
if($("#tt_daytype option:selected").text() == "Working")
{
return (( $("#tt_workinghours option:selected").text() != "Select"));
}
else{
return (( $("#tt_workinghours option:selected").text() == "Select"));
}
};
Page_Validators.push(workingHoursValidator);
//* Working Hours Validation *//
//* Other Details Validation *//
var otherDetailsValidator = document.createElement('span');
otherDetailsValidator.id = "otherDetailsValidator";
otherDetailsValidator.errormessage = "Other Details must contain a value";
otherDetailsValidator.evaluationfunction = function()
{
if(($("#tt_daytype option:selected").text() == "Other") || $("#tt_daytype option:selected").text() == "Travelling")
{
return (( $("#tt_daytypeother").val() != ""));
}
else{
return (( $("#tt_daytypeother").val() == ""));
}
};
Page_Validators.push(otherDetailsValidator);
//* Other Details Validation *//
}
catch (e)
{
alert("Error during validation:" + e.description);
}
prepareForm();
$("#tt_locationcountry").change(toggleStateField);
$("#tt_locationstate").change(toggleCityField);
$("#tt_daytype").change(toggleDayDetails);
var startdatedatePicker = $('#tt_startdate_datepicker_description').parent()
startdatedatePicker.on('dp.change', function (event) {
$("#tt_enddate").val($("#tt_startdate").val())
});
toggleDayDetails();
});
function toggleStateField(){
var country = $("#tt_locationcountry_name").val();
switch(country) {
case "United States of America":
$("#tt_locationstate").closest('td').show();
$("#tt_locationstate_label").parent().addClass("required");
break;
default:
$("#tt_locationstate").val('');
$("#tt_locationstate_name").val('');
$("#tt_locationstate").closest('td').hide();
$("#tt_locationstate_label").parent().removeClass("required");
$("#tt_locationcity").val('');
$("#tt_locationcity_name").val('');
$("#tt_locationcity").closest('td').hide();
$("#tt_locationcity_label").parent().removeClass("required");
}
}
function toggleCityField(){
var state = $("#tt_locationstate_name").val();
switch(state) {
case "New York":
$("#tt_locationcity").closest('td').show();
$("#tt_locationcity_label").parent().addClass("required");
break;
default:
$("#tt_locationcity").val('');
$("#tt_locationcity_name").val('');
$("#tt_locationcity").closest('td').hide();
$("#tt_locationcity_label").parent().removeClass("required");
}
}
function toggleDayDetails(){
var dayType = $("#tt_daytype option:selected").text();
var dayTypeVal = $("#tt_daytype option:selected").val();
$("#tt_daytype").val(dayTypeVal);
switch(dayType)
{
case "Working":
$("#tt_daytypeother").closest('tr').hide();
$("#tt_daytypeother_label").parent().removeClass("required");
$("#tt_workinghours").closest('td').show();
$("#tt_workinghours_label").parent().addClass("required");
break;
case "Other":
$("#tt_daytypeother").closest('tr').show();
$("#tt_daytypeother_label").parent().addClass("required");
$("#tt_workinghours").closest('td').hide();
$("#tt_workinghours_label").parent().removeClass("required");
$("#tt_workinghours").val('');
break;
case "Travelling":
$("#tt_daytypeother").closest('tr').show();
$("#tt_daytypeother_label").parent().addClass("required");
$("#tt_workinghours").closest('td').hide();
$("#tt_workinghours_label").parent().removeClass("required");
$("#tt_workinghours").val('');
break;
default:
$("#tt_daytypeother").closest('tr').hide();
$("#tt_daytypeother_label").parent().removeClass("required");
$("#tt_daytypeother").val('');
$("#tt_workinghours").closest('td').hide();
$("#tt_workinghours_label").parent().removeClass("required");
$("#tt_workinghours").val('');
}
}
function prepareForm(){
toggleStateField();
toggleCityField();
$('input#tt_enddate').closest('td').hide();
if($('div.form-readonly[readonly="readonly"]').length > 0){
$('button.delete-link').remove()
}
var submitButton = document.getElementById("UpdateButton");
submitButton.addEventListener('click', function() { parent.reloadWindow("UpdateButton", "EditFrame") } );
}
Calendar Edit - Working Hours
| Name | Type | Attribute Logical Name |
|---|---|---|
| Calendar Edit - Working Hours | Attribute | Working Hours (tt_workinghours) |
| Label |
|---|
| Working Hours (Full / Half Day) |
Calendar Edit - Country
| Name | Type | Attribute Logical Name |
|---|---|---|
| Calendar Edit - Country | Attribute | Location - Country (tt_locationcountry) |
| Label |
|---|
| Select Country |
Calendar Edit - State
| Name | Type | Attribute Logical Name |
|---|---|---|
| Calendar Edit - State | Attribute | Location - State (tt_locationstate) |
| Label |
|---|
| Select State |
Calendar Edit - City
| Name | Type | Attribute Logical Name |
|---|---|---|
| Calendar Edit - City | Attribute | Location - City (tt_locationcity) |
| Label |
|---|
| Select City |
Calendar Edit - Other Details
| Name | Type | Attribute Logical Name |
|---|---|---|
| Other Details | Attribute | Day Type - Other (tt_daytypeother) |
| Add Description |
|---|
| Yes |
| Position | Use Attribute's Description Property |
|---|---|
| Yes | No |
| Description |
|---|
| Please provide further details. For travel days, please include your local departure and arrival timings, flight number etc. |
Calendar - New
- General
- Additional Settings
- Entity Form Metadata
| Table Name | Form Name | Tab Name | Mode | Enable Table Permissions |
|---|---|---|---|---|
| Calendar (tt_calendar) | Portal - Main | General | Insert | true |
Associate Current Portal User on Insert
| Associate Current Portal User | Portal User Lookup Column |
|---|---|
| true | Contact (tt_contact) |
Custom JavaScript
$(document).ready(function() {
try {
if (typeof(Page_Validators) == 'undefined') return;
//* Date Range Validation *//
var dateRangeValidator = document.createElement('span');
dateRangeValidator.id = "dateRangeValidator";
dateRangeValidator.errormessage = "End Date cannot be before Start Date ";
dateRangeValidator.evaluationfunction = function()
{
var startDate = new Date($("#tt_startdate").val());
var endDate = new Date($("#tt_enddate").val());
return (( startDate <= endDate ));
};
Page_Validators.push(dateRangeValidator);
//* Date Range Validation *//
//* Country Validation *//
var countryValidator = document.createElement('span');
countryValidator.id = "countryValidator";
countryValidator.errormessage = "A Country must be selected";
countryValidator.evaluationfunction = function()
{
return (( $("#tt_locationcountry").val() != ""));
};
Page_Validators.push(countryValidator);
//* States Validation *//
//* States Validation *//
var stateValidator = document.createElement('span');
stateValidator.id = "stateValidator";
stateValidator.errormessage = "A State must be selected";
stateValidator.evaluationfunction = function()
{
if ($("#tt_locationcountry_name").val() == "United States of America"){
return (( $("#tt_locationstate").val() != ""))
}
else{
return (( $("#tt_locationstate").val() == ""));
}
};
Page_Validators.push(stateValidator);
//* States Validation *//
//* City Validation *//
var cityValidator = document.createElement('span');
cityValidator.id = "cityValidator";
cityValidator.errormessage = "A City must be selected";
cityValidator.evaluationfunction = function()
{
if ($("#tt_locationstate_name").val() == "New York"){
return (( $("#tt_locationcity").val() != ""))
}
else{
return (( $("#tt_locationcity").val() == ""));
}
};
Page_Validators.push(cityValidator);
//* City Validation *//
//* Day Type Validation *//
var dayTypeValidator = document.createElement('span');
dayTypeValidator.id = "dayTypeValidator";
dayTypeValidator.errormessage = "A Type must be selected";
dayTypeValidator.evaluationfunction = function()
{
return (( $("#tt_daytype option:selected").text() != " "))
};
Page_Validators.push(dayTypeValidator);
//* Day Type Validation *//
//* Working Hours Validation *//
var workingHoursValidator = document.createElement('span');
workingHoursValidator.id = "workingHoursValidator";
workingHoursValidator.errormessage = "Working Hours must be selected";
workingHoursValidator.evaluationfunction = function()
{
if($("#tt_daytype option:selected").text() == "Working")
{
return (( $("#tt_workinghours option:selected").text() != "Select"));
}
else{
return (( $("#tt_workinghours option:selected").text() == "Select"));
}
};
Page_Validators.push(workingHoursValidator);
//* Working Hours Validation *//
//* Other Details Validation *//
var otherDetailsValidator = document.createElement('span');
otherDetailsValidator.id = "otherDetailsValidator";
otherDetailsValidator.errormessage = "Other Details must contain a value";
otherDetailsValidator.evaluationfunction = function()
{
if(($("#tt_daytype option:selected").text() == "Other") || $("#tt_daytype option:selected").text() == "Travelling")
{
return (( $("#tt_daytypeother").val() != ""));
}
else{
return (( $("#tt_daytypeother").val() == ""));
}
};
Page_Validators.push(otherDetailsValidator);
//* Other Details Validation *//
}
catch (e)
{
alert("Error during validation:" + e.description);
}
prepareForm();
$("#tt_locationcountry").change(toggleStateField);
$("#tt_locationstate").change(toggleCityField);
$("#tt_daytype").change(toggleDayDetails);
toggleDayDetails();
});
function toggleStateField(){
var country = $("#tt_locationcountry_name").val();
switch(country) {
case "United States of America":
$("#tt_locationstate").closest('td').show();
$("#tt_locationstate_label").parent().addClass("required");
break;
default:
$("#tt_locationstate").val('');
$("#tt_locationstate_name").val('');
$("#tt_locationstate").closest('td').hide();
$("#tt_locationstate_label").parent().removeClass("required");
$("#tt_locationcity").val('');
$("#tt_locationcity_name").val('');
$("#tt_locationcity").closest('td').hide();
$("#tt_locationcity_label").parent().removeClass("required");
}
}
function toggleCityField(){
var state = $("#tt_locationstate_name").val();
switch(state) {
case "New York":
$("#tt_locationcity").closest('td').show();
$("#tt_locationcity_label").parent().addClass("required");
break;
default:
$("#tt_locationcity").val('');
$("#tt_locationcity_name").val('');
$("#tt_locationcity").closest('td').hide();
$("#tt_locationcity_label").parent().removeClass("required");
}
}
function toggleDayDetails(){
var dayType = $("#tt_daytype option:selected").text();
var dayTypeVal = $("#tt_daytype option:selected").val();
$("#tt_daytype").val(dayTypeVal);
switch(dayType)
{
case "Working":
$("#tt_daytypeother").closest('tr').hide();
$("#tt_daytypeother_label").parent().removeClass("required");
$("#tt_workinghours").closest('td').show();
$("#tt_workinghours_label").parent().addClass("required");
break;
case "Other":
$("#tt_daytypeother").closest('tr').show();
$("#tt_daytypeother_label").parent().addClass("required");
$("#tt_workinghours").closest('td').hide();
$("#tt_workinghours_label").parent().removeClass("required");
$("#tt_workinghours").val('');
break;
case "Travelling":
$("#tt_daytypeother").closest('tr').show();
$("#tt_daytypeother_label").parent().addClass("required");
$("#tt_workinghours").closest('td').hide();
$("#tt_workinghours_label").parent().removeClass("required");
$("#tt_workinghours").val('');
break;
default:
$("#tt_daytypeother").closest('tr').hide();
$("#tt_daytypeother_label").parent().removeClass("required");
$("#tt_daytypeother").val('');
$("#tt_workinghours").closest('td').hide();
$("#tt_workinghours_label").parent().removeClass("required");
$("#tt_workinghours").val('');
}
}
function prepareForm(){
toggleStateField();
toggleCityField();
$("#tt_locationcountry_label").parent().addClass("required");
var submitButton = document.getElementById("InsertButton");
submitButton.addEventListener('click', function() { parent.reloadWindow("InsertButton", "CreateFrame") } );
if($('#tt_startdate').length > 0)
{
var inputDate = localStorage.getItem("inputDate")
var formattedDate = Date.parse(inputDate).format("yyyy-MM-ddT00:00:00.0000000");
$('#tt_startdate').attr('value', formattedDate);
$('#tt_enddate').attr('value', formattedDate);
$('#tt_startdate_datepicker_description').attr('placeholder',Date.parse(inputDate).format("dd/MM/yyyy") );
$('#tt_enddate_datepicker_description').attr('placeholder',Date.parse(inputDate).format("dd/MM/yyyy") );
var countryid = localStorage.getItem("unitedKingdom");
var CountryName = localStorage.getItem("unitedKingdomname");
$('#tt_locationcountry_name').attr('value', CountryName);
$('#tt_locationcountry').attr('value', countryid);
}
else{
window.setTimeout(prepareForm, 250);
}
$("#InsertButton").parent().closest('#content').append('<input type="checkbox" id="overwriteData" name="Overwrite Existing Data" value="overwriteData"><label class="field-label" for="overwriteData">Overwrite Existing Data?</label><br/>');
$("#InsertButton").parent().closest('#content').append('<button id="CreateButton" class="btn btn-primary" onclick="DataProcessing()">Create</button>');
$("#InsertButton").hide()
}
function DataProcessing(){
var validationResponse = FormValidation();
if(validationResponse){
var start = new Date($("#tt_startdate").val());
var startDate = Date.parse(start).format("yyyy-MM-dd")
var end = new Date($("#tt_enddate").val());
var endDate = Date.parse(end).format("yyyy-MM-dd")
var country = $("#tt_locationcountry").val();
var state = $("#tt_locationstate").val();
var city = $("#tt_locationcity").val();
var inCountryAtMidnight = $('input#tt_incountryatmidnight').prop('checked');
var dayType = $("#tt_daytype option:selected").val();
var workingHours = $("#tt_workinghours option:selected").val();
var otherDetails = $("#tt_daytypeother").val();
var notes = $("#tt_notes").val();
let overwriteData = $('#overwriteData').is(':checked');
console.log("Overwriting Data: " + overwriteData)
$('#CreateButton').text("");
$('#CreateButton').append('<span class="fa fa-cog fa-spin" style="display: inline-block !important" aria-hidden="true">');
$('#CreateButton').append(" Processing ");
$('#CreateButton').prop("disabled",true);
$('#CreateButton').parent().append('<span id="creationLog" style="float:right"><span>')
parent.AddNewRecords(startDate,endDate,country,state,city,inCountryAtMidnight,dayType,workingHours,otherDetails,notes,overwriteData)
}
}
function FormValidation(){
if(typeof entityFormClientValidate === 'function')
{
if(entityFormClientValidate())
{
if(typeof Page_ClientValidate === 'function')
{
if(Page_ClientValidate(''))
{
return true;
}
}
else
{
return true;
}
}
else
{
return false;
}
}
else
{
if(typeof Page_ClientValidate === 'function')
{
if(Page_ClientValidate(''))
{
return true;
}
}
else
{
return true;
}
}
}
Calendar New - Start Date
| Name | Type | Attribute Logical name |
|---|---|---|
| Calendar New - Start Date | Attribute | Start Date (tt_startdate) |
Calendar New - End Date
| Name | Type | Attribute Logical name |
|---|---|---|
| Calendar New - End Date | Attribute | End Date (tt_enddate) |
Calendar New - Working Hours
| Name | Type | Attribute Logical Name |
|---|---|---|
| Calendar New - Working Hours | Attribute | Working Hours (tt_workinghours) |
| Label |
|---|
| Working Hours (Full / Half Day) |
Calendar New - Country
| Name | Type | Attribute Logical Name |
|---|---|---|
| Calendar New - Country | Attribute | Location - Country (tt_locationcountry) |
| Label |
|---|
| Select Country |
Calendar New - State
| Name | Type | Attribute Logical Name |
|---|---|---|
| Calendar New - State | Attribute | Location - State (tt_locationstate) |
| Label |
|---|
| Select State |
Calendar New - City
| Name | Type | Attribute Logical Name |
|---|---|---|
| Calendar New - City | Attribute | Location - City (tt_locationcity) |
| Label |
|---|
| Select City |
Calendar New - Other Details
| Name | Type | Attribute Logical Name |
|---|---|---|
| Other Details | Attribute | Day Type - Other (tt_daytypeother) |
| Add Description |
|---|
| Yes |
| Position | Use Attribute's Description Property |
|---|---|
| Yes | No |
| Description |
|---|
| Please provide further details. For travel days, please include your local departure and arrival timings, flight number etc. |
Calendar - Set Up
- General
- Additional Settings
- Entity Form Metadata
| Table Name | Form Name | Tab Name | Mode | Enable Table Permissions |
|---|---|---|---|---|
| Calendar Working Pattern (tt_calendarworkingpattern) | Portal | General | Insert | true |
Associate Current Portal User on Insert
| Associate Current Portal User | Portal User Lookup Column |
|---|---|
| true | Contact (tt_contact) |
Custom JavaScript
$(document).ready(function() {
try {
if (typeof(Page_Validators) == 'undefined') return;
//* Start Date Validation *//
var startDateValidator = document.createElement('span');
startDateValidator.id = "startDateValidator";
startDateValidator.errormessage = "Start Date must be selected";
startDateValidator.evaluationfunction = function()
{
return (( $("#tt_startdate").val() != ""));
};
Page_Validators.push(startDateValidator);
//* Start Date Validation *//
//* Start Date Validation *//
var endDateValidator = document.createElement('span');
endDateValidator.id = "endDateValidator";
endDateValidator.errormessage = "End Date must be selected";
endDateValidator.evaluationfunction = function()
{
return (( $("#tt_enddate").val() != ""));
};
Page_Validators.push(endDateValidator);
//* Start Date Validation *//
//* Date Range Validation *//
var dateRangeValidator = document.createElement('span');
dateRangeValidator.id = "dateRangeValidator";
dateRangeValidator.errormessage = "End Date cannot be before Start Date ";
dateRangeValidator.evaluationfunction = function()
{
var startDate = new Date($("#tt_startdate").val());
var endDate = new Date($("#tt_enddate").val());
return (( startDate <= endDate ));
};
Page_Validators.push(dateRangeValidator);
//* Date Range Validation *//
//* Country Validation *//
var countryValidator = document.createElement('span');
countryValidator.id = "countryValidator";
countryValidator.errormessage = "A Country must be selected";
countryValidator.evaluationfunction = function()
{
return (( $("#tt_country").val() != ""));
};
Page_Validators.push(countryValidator);
//* States Validation *//
//* States Validation *//
var stateValidator = document.createElement('span');
stateValidator.id = "stateValidator";
stateValidator.errormessage = "A State must be selected";
stateValidator.evaluationfunction = function()
{
if ($("#tt_country_name").val() == "United States of America"){
return (( $("#tt_state").val() != ""))
}
else{
return (( $("#tt_state").val() == ""));
}
};
Page_Validators.push(stateValidator);
//* States Validation *//
//* City Validation *//
var cityValidator = document.createElement('span');
cityValidator.id = "cityValidator";
cityValidator.errormessage = "A City must be selected";
cityValidator.evaluationfunction = function()
{
if ($("#tt_state_name").val() == "New York"){
return (( $("#tt_city").val() != ""))
}
else{
return (( $("#tt_city").val() == ""));
}
};
Page_Validators.push(cityValidator);
//* City Validation *//
//* Working Hours Validation *//
var workingHoursValidator = document.createElement('span');
workingHoursValidator.id = "workingHoursValidator";
workingHoursValidator.errormessage = "Working Hours must be selected";
workingHoursValidator.evaluationfunction = function()
{
return (( $("#tt_workinghours option:selected").text() != "Select"));
};
Page_Validators.push(workingHoursValidator);
//* Working Hours Validation *//
}
catch (e)
{
alert("Error during validation:" + e.description);
}
prepareForm();
$("#tt_country").change(toggleStateField);
$("#tt_state").change(toggleCityField);
});
function toggleStateField(){
var country = $("#tt_country_name").val();
switch(country) {
case "United States of America":
$("#tt_state").closest('td').show();
$("#tt_state_label").parent().addClass("required");
break;
default:
$("#tt_state").val('');
$("#tt_state_name").val('');
$("#tt_state").closest('td').hide();
$("#tt_state_label").parent().removeClass("required");
$("#tt_city").val('');
$("#tt_city_name").val('');
$("#tt_city").closest('td').hide();
$("#tt_city_label").parent().removeClass("required");
}
}
function toggleCityField(){
var state = $("#tt_state_name").val();
switch(state) {
case "New York":
$("#tt_city").closest('td').show();
$("#tt_city_label").parent().addClass("required");
break;
default:
$("#tt_city").val('');
$("#tt_city_name").val('');
$("#tt_city").closest('td').hide();
$("#tt_city_label").parent().removeClass("required");
}
}
function prepareForm(){
$("#tt_state").closest('td').hide();
$("#tt_city").closest('td').hide();
$("#tt_startdate_label").parent().addClass("required");
$("#tt_enddate_label").parent().addClass("required");
$("#tt_country_label").parent().addClass("required");
$("#InsertButton").parent().closest('#content').append('<input type="checkbox" id="overwriteData" name="Overwrite Existing Data" value="overwriteData"><label class="field-label" for="overwriteData">Overwrite Existing Data?</label><br/>');
$("#InsertButton").parent().closest('#content').append('<button id="CreateButton" class="btn btn-primary" onclick="DataProcessing()">Create</button>');
$("#InsertButton").hide()
if($('#tt_startdate').length > 0)
{
var countryid = localStorage.getItem("unitedKingdom");
var CountryName = localStorage.getItem("unitedKingdomname");
$('#tt_country_name').attr('value', CountryName);
$('#tt_country').attr('value', countryid);
}
else{
window.setTimeout(prepareForm, 250);
}
}
function DataProcessing(){
var validationResponse = FormValidation();
if(validationResponse){
var start = new Date($("#tt_startdate").val());
var startDate = Date.parse(start).format("yyyy-MM-dd")
var end = new Date($("#tt_enddate").val());
var endDate = Date.parse(end).format("yyyy-MM-dd")
var monday = $('input#tt_monday').prop('checked');
var tuesday = $('input#tt_tuesday').prop('checked');
var wednesday = $('input#tt_wednesday').prop('checked');
var thursday = $('input#tt_thursday').prop('checked');
var friday = $('input#tt_friday').prop('checked');
var saturday = $('input#tt_saturday').prop('checked');
var sunday = $('input#tt_sunday').prop('checked');
var workingHours = $("#tt_workinghours option:selected").val();
var country = $("#tt_country").val();
var state = $("#tt_state").val();
var city = $("#tt_city").val();
let overwriteData = $('#overwriteData').is(':checked');
console.log("Overwriting Data: " + overwriteData)
$('#CreateButton').text("");
$('#CreateButton').append('<span class="fa fa-cog fa-spin" style="display: inline-block !important" aria-hidden="true">');
$('#CreateButton').append(" Processing ");
$('#CreateButton').prop("disabled",true);
$('#CreateButton').parent().append('<span id="workingPeriodLog" style="float:right"><span>')
parent.GiveMeRecords(startDate,endDate,monday,tuesday,wednesday,thursday,friday,saturday,sunday,workingHours,country,state,city,overwriteData)
}
//var validationResponse = ValidateForm();
}
function FormValidation(){
if(typeof entityFormClientValidate === 'function')
{
if(entityFormClientValidate())
{
if(typeof Page_ClientValidate === 'function')
{
if(Page_ClientValidate(''))
{
return true;
}
}
else
{
return true;
}
}
else
{
return false;
}
}
else
{
if(typeof Page_ClientValidate === 'function')
{
if(Page_ClientValidate(''))
{
return true;
}
}
else
{
return true;
}
}
}
Calendar Set up - Start Date
| Name | Type | Attribute Logical name |
|---|---|---|
| Calendar Set up - Start Date | Attribute | Start Date (tt_startdate) |
Calendar Set up - End Date
| Name | Type | Attribute Logical name |
|---|---|---|
| Calendar Set up - End Date | Attribute | End Date (tt_enddate) |
Calendar Set up - Working Hours
| Name | Type | Attribute Logical Name |
|---|---|---|
| Calendar NSet upew - Working Hours | Attribute | Working Hours (tt_workinghours) |
| Label |
|---|
| Working Hours (Full / Half Day) |
Calendar Set up - Country
| Name | Type | Attribute Logical Name |
|---|---|---|
| Calendar Set up - Country | Attribute | Country (tt_country) |
| Label |
|---|
| Select Country |
Calendar Set up - State
| Name | Type | Attribute Logical Name |
|---|---|---|
| Calendar Set up - State | Attribute | State (tt_state) |
| Label |
|---|
| Select State |
Calendar Set up - City
| Name | Type | Attribute Logical Name |
|---|---|---|
| Calendar Set up - City | Attribute | City (tt_city) |
| Label |
|---|
| Select City |
Calendar - Submission
- General
- Additional Settings
| Table Name | Form Name | Tab Name | Mode | Enable Table Permissions |
|---|---|---|---|---|
| Calendar (tt_calendar) | Portal - Submission | General | Insert | true |
Custom JavaScript
$(document).ready(function() {
{{ snippets["WrapperAJAX"] }};
try {
if (typeof(Page_Validators) == 'undefined') return;
//* Start Date Validation *//
var startDateValidator = document.createElement('span');
startDateValidator.id = "startDateValidator";
startDateValidator.errormessage = "Start Date must be selected";
startDateValidator.evaluationfunction = function()
{
return (( $("#tt_startdate").val() != ""));
};
Page_Validators.push(startDateValidator);
//* Start Date Validation *//
//* Start Date Validation *//
var endDateValidator = document.createElement('span');
endDateValidator.id = "endDateValidator";
endDateValidator.errormessage = "End Date must be selected";
endDateValidator.evaluationfunction = function()
{
return (( $("#tt_enddate").val() != ""));
};
Page_Validators.push(endDateValidator);
//* Start Date Validation *//
//* Date Range Validation *//
var dateRangeValidator = document.createElement('span');
dateRangeValidator.id = "dateRangeValidator";
dateRangeValidator.errormessage = "End Date cannot be before Start Date ";
dateRangeValidator.evaluationfunction = function()
{
var startDate = new Date($("#tt_startdate").val());
var endDate = new Date($("#tt_enddate").val());
return (( startDate <= endDate ));
};
Page_Validators.push(dateRangeValidator);
}
catch (e)
{
alert("Error during validation:" + e.description);
}
prepareForm();
});
function prepareForm(){
$("#tt_startdate_label").parent().addClass("required");
$("#tt_enddate_label").parent().addClass("required");
$("#InsertButton").parent().closest('#content').append('<button id="SubmissionButton" class="btn btn-primary" onclick="DataProcessing()">Submit</button>');
$("#InsertButton").hide()
}
async function DataProcessing(){
var validationResponse = FormValidation();
if(validationResponse)
{
var start = new Date($("#tt_startdate").val());
var startDate = Date.parse(start).format("yyyy-MM-dd")
var end = new Date($("#tt_enddate").val());
var endDate = Date.parse(end).format("yyyy-MM-dd")
$('#SubmissionButton').text("");
$('#SubmissionButton').append('<span class="fa fa-cog fa-spin" style="display: inline-block !important" aria-hidden="true">');
$('#SubmissionButton').append(" Processing ");
$('#SubmissionButton').prop("disabled",true);
$('.submissionError').remove()
$('#SubmissionButton').parent().append('<span id="submissionLog" style="float:right"><span>')
CheckSubmissionStatus(startDate, endDate);
}
}
async function CheckSubmissionStatus(startDate, endDate)
{
//Check to see if all dates have completed Data
const results = await parent.checkValidSubmission(startDate, endDate);
const isArrayOfGUIDs = results.every(item => typeof item === 'string' && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(item));
const isArrayOfDates = results.every(item => {
const dateRegex = /^\d{2}\/\d{2}\/\d{4}$/;
const [month, day, year] = item.split('/').map(Number);
return dateRegex.test(item) && !isNaN(month) && !isNaN(day) && !isNaN(year);
});
if (isArrayOfGUIDs)
{
//Submit all records
parent.submitDates(results);
}
else if (isArrayOfDates)
{
//Display an alert stating that data is missing
$('#SubmissionButton').text("Submit");
var alertbox = `<div id="ValidationSummaryEntityFormControl_EntityFormView" class="validation-summary alert alert-error alert-danger alert-block submissionError" style="" tabindex="0">
<h2 class="validation-header" role="none">
<span role="presentation" class="fa fa-info-circle"></span>
The form could not be submitted for the following reasons:
</h2>
<ul role="presentation">`
for (let i = 0; i < results.length; i++) {
var missingDate = Date.parse(results[i]).format("dd/MM/yyyy")
alertbox = alertbox + `<li>` + missingDate + ` : Does not have a record where you are at midnight` + `</li>`
}
alertbox = alertbox + `</ul></div>`
$('div.validation-summary').parent().prepend(alertbox)
$('#SubmissionButton').prop("disabled",false);
}
else
{
console.log('Unknown array type');
}
}
function FormValidation(){
if(typeof entityFormClientValidate === 'function')
{
if(entityFormClientValidate())
{
if(typeof Page_ClientValidate === 'function')
{
if(Page_ClientValidate(''))
{
return true;
}
}
else
{
return true;
}
}
else
{
return false;
}
}
else
{
if(typeof Page_ClientValidate === 'function')
{
if(Page_ClientValidate(''))
{
return true;
}
}
else
{
return true;
}
}
}